package com.itheima.d7_thread_communication;

public class Cook implements Runnable {
    @Override
    public void run() {
        while (true) {
            synchronized (Desk.class) {
                if (!Desk.falg) {
                    System.out.println(Thread.currentThread().getName()+"厨师蒸包子");
                    Desk.falg = true;
                    try {
                        Thread.sleep(100);

                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                        Desk.class.notify();
                    try {
                        Desk.class.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }else {
                    System.out.println(Thread.currentThread().getName()+"厨师白跑");
                }
            }

        }
    }
}
